#!/usr/bin/env python3

import json
import pprint
import os.path
# import sqlite3 as sql


book = os.path.join(os.path.dirname(__file__), 'addrbook.json')
with open(book, 'rt') as f:
    addresses = json.load(f)
# pprint.pprint(addresses)


def show(name="__all__"):
    if name == "__all__":
        for n, a in addresses.items():
            print("  %s: %s" % (n, a))
    else:
        try:
            print("  %s: %s" % (name, addresses[name]))
        except KeyError:
            print("- *** Can't find the addrbook of the name '%s' " % name)


# def add(name, address):
#     if addresses.get(name, None):
#         addresses[name].append(address)
#     else:
#         addresses[name] = [ address, ]
#     # write to file
# def update(name, ): pass

def use(name, index=0):
    pass



def main(opts, help):
    show(opts.name)